//
// Created by 123 on 2025/1/10.
//
#include "algorithm"
#include "vector"
#include "iostream"


//普通函数
void print01(int val){
    std::cout << val << std::endl;
}
//函数对象
class Print02{
public:
    void operator()(int val){
        std::cout << val << std::endl;
    }
};

void testForEach(){
    std::vector<int> v;
    for (int i = 0; i < 10; ++i) {
        v.push_back(i);
    }

    //遍历算法
    std::for_each(v.begin(),v.end(), Print02());
    std::cout << "---------------" << std::endl;
    std::for_each(v.begin(),v.end(), print01);

}

int main150(){
    testForEach();
    return 0;
}